﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Model.Vote;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
namespace Enterprise.Data.Vote
{
   public class VoteItemData
    {
        /// <summary>
        ///  数据列表
        /// </summary>
        /// <returns></returns>
        public List<VoteItemEntity> VoteItemList(string voteId)
        {
            List<VoteItemEntity> list = new List<VoteItemEntity>();
            string cmd = "Select * from VOTE_ITEM where VID='" + voteId + "'";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                VoteItemEntity entity = new VoteItemEntity();
                if (!Convert.IsDBNull(dr["VITEMID"])) entity.VITEMID = Convert.ToInt32(dr["VITEMID"]);
                if (!Convert.IsDBNull(dr["VID"])) entity.VID = Convert.ToString(dr["VID"]);
                if (!Convert.IsDBNull(dr["VITEMCODE"])) entity.VITEMCODE = Convert.ToString(dr["VITEMCODE"]);
                if (!Convert.IsDBNull(dr["VITEMTITLE"])) entity.VITEMTITLE = Convert.ToString(dr["VITEMTITLE"]);
                if (!Convert.IsDBNull(dr["VITEMREMARK"])) entity.VITEMREMARK = Convert.ToString(dr["VITEMREMARK"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void Execute(string cmd)
        {
            DbExecute.Execute(cmd);
        }
    }
}
